#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1e5 + 10 , MOD = 1e9 + 7;
string str;
int dp[N][13];
int main()
{
    cin >> str;
    int n = str.size();
    str = str + '0';

    dp[0][0] = 1;
    for (int i = 1; i <= n; i ++) {
        if (str[i - 1] == '?') {
            for (int now = 0; now < 10; now ++) {
                for (int k = 0; k < 13; k ++) {
                    dp[i][(now + k * 10) % 13] = (dp[i][(now + k * 10) % 13] + dp[i - 1][k]) % mod;
                }
            }
        }
        else {
            int now = str[i - 1] - '0';
            for (int k = 0; k < 13; k ++) dp[i][(now + k * 10) % 13] = (dp[i][(now + k * 10) % 13] + dp[i - 1][k]) % mod;
        }
    }   
    cout << dp[n][5] << endl;
    return 0;
}